home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / MoreFiles 1.3.1 / MoreFilesExtras.p < prev    next >
Encoding:
Text File  |  1995-06-08  |  57.0 KB  |  1,475 lines  |  [TEXT/MWPS]

  1. UNIT MoreFilesExtras;
  2.  
  3. {    Apple Macintosh Developer Technical Support                                }
  4. {                                                                            }
  5. {    A collection of useful high-level File Manager routines.                }
  6. {    by Jim Luther, Apple Developer Technical Support                        }
  7. {                                                                            }
  8. {    File:        MoreFilesExtras.p                                            }
  9. {                                                                            }
  10. {    Copyright © 1992-1995 Apple Computer, Inc.                                }
  11. {    All rights reserved.                                                    }
  12. {                                                                            }
  13. {    You may incorporate this sample code into your applications without        }
  14. {    restriction, though the sample code has been provided "AS IS" and the    }
  15. {    responsibility for its operation is 100% yours.  However, what you are    }
  16. {    not permitted to do is to redistribute the source as "DSC Sample Code"    }
  17. {    after having made changes. If you're going to re-distribute the source,    }
  18. {    we require that you make it clear in the source that the code was        }
  19. {    descended from Apple Sample Code, but that you've made changes.            }
  20.  
  21.  
  22. INTERFACE
  23.  
  24. USES
  25.     Files;
  26.  
  27. {    Deny mode permissions for use with the HOpenAware, HOpenRFAware,        }
  28. {    FSpOpenAware, and FSpOpenRFAware functions.                                }
  29.  
  30.     CONST
  31.         dmNone = $0000;
  32.         dmNoneDenyRd = $0010;
  33.         dmNoneDenyWr = $0020;
  34.         dmNoneDenyRdWr = $0030;
  35.         dmRd = $0001;            { Single writer, multiple readers; the readers }
  36.         dmRdDenyRd = $0011;
  37.         dmRdDenyWr = $0021;        { Browsing - equivalent to fsRdPerm }
  38.         dmRdDenyRdWr = $0031;
  39.         dmWr = $0002;
  40.         dmWrDenyRd = $0012;
  41.         dmWrDenyWr = $0022;
  42.         dmWrDenyRdWr = $0032;
  43.         dmRdWr = $0003;            { Shared access - equivalent to fsRdWrShPerm }
  44.         dmRdWrDenyRd = $0013;
  45.         dmRdWrDenyWr = $0023;    { Single writer, multiple readers; the writer }
  46.         dmRdWrDenyRdWr = $0033;    { Exclusive access - equivalent to fsRdWrPerm }
  47.  
  48.  
  49. {    For those times where you need to use more than one kind of                }
  50. {    File Manager parameter block but don't feel like wasting stack space,    }
  51. {    here's a parameter block you can reuse.                                    }
  52.  
  53.     TYPE
  54.         UniversalFMPBHandle = ^UniversalFMPBPtr;
  55.         UniversalFMPBPtr = ^UniversalFMPB;
  56.         UniversalFMPB = RECORD
  57.                 CASE Integer OF
  58.                     1: (
  59.                             PB: ParamBlockRec
  60.                     );
  61.                     2: (
  62.                             ciPB: CInfoPBRec
  63.                     );
  64.                     3: (
  65.                             dtPB: DTPBRec
  66.                     );
  67.                     4: (
  68.                             hPB: HParamBlockRec
  69.                     );
  70.                     5: (
  71.                             cmPB: CMovePBRec
  72.                     );
  73.                     6: (
  74.                             wdPB: WDPBRec
  75.                     );
  76.                     7: (
  77.                             fcbPB: FCBPBRec
  78.                     );
  79.             END;
  80.  
  81.  
  82. {    Used by GetUGEntries to return user or group lists.                        }
  83.  
  84.         UGEntryHandle = ^UGEntryPtr;
  85.         UGEntryPtr = ^UGEntry;
  86.         UGEntry = RECORD
  87.                 objType: Integer;
  88.                 objID: LongInt;
  89.                 name: Str31;
  90.             END;
  91.  
  92.  
  93. {    I use the following record instead of the AFPVolMountInfo structure        }
  94. {    in Files.p                                                                }
  95.  
  96.         Str8 = STRING[8];
  97.         MyAFPVolMountInfoHandle = ^MyAFPVolMountInfoPtr;
  98.         MyAFPVolMountInfoPtr = ^MyAFPVolMountInfo;
  99.         MyAFPVolMountInfo = RECORD
  100.                 length: Integer;                { length of this record }
  101.                 media: VolumeType;                { type of media, always AppleShareMediaType }
  102.                 flags: Integer;                    { 0 = normal mount; set bit 0 to inhibit greeting messages }
  103.                 nbpInterval: SignedByte;        { NBP interval parameter; 7 is a good choice }
  104.                 nbpCount: SignedByte;            { NBP count parameter; 5 is a good choice }
  105.                 uamType: Integer;                { User Authentication Method }
  106.                 zoneNameOffset: Integer;        { offset from start of record to zoneName }
  107.                 serverNameOffset: Integer;        { offset from start of record to serverName }
  108.                 volNameOffset: Integer;            { offset from start of record to volName }
  109.                 userNameOffset: Integer;        { offset from start of record to userName }
  110.                 userPasswordOffset: Integer;    { offset from start of record to userPassword }
  111.                 volPasswordOffset: Integer;        { offset from start of record to volPassword }
  112.                 zoneName: Str31;                { server's AppleTalk zone name }
  113.                 serverName: Str31;                { server name }
  114.                 volName: Str27;                    { volume name }
  115.                 userName: Str31;                { user name (zero length Pascal string for guest) }
  116.                 userPassword: Str8;                { user password (zero length Pascal string if no user password) }
  117.                 volPassword: Str8;                { volume password (zero length Pascal string if no volume password) }
  118.             END;
  119.  
  120.  
  121. {***************************************************************************}
  122.  
  123. {    Functions to get information out of GetVolParmsInfoBuffer (implemented    }
  124. {    in this Unit).                                                            }
  125.  
  126.     FUNCTION isNetworkVolume (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  127.     FUNCTION hasLimitFCBs (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  128.     FUNCTION hasLocalWList (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  129.     FUNCTION hasNoMiniFndr (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  130.     FUNCTION hasNoVNEdit (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  131.     FUNCTION hasNoLclSync (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  132.     FUNCTION hasTrshOffLine (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  133.     FUNCTION hasNoSwitchTo (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  134.     FUNCTION hasNoDeskItems (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  135.     FUNCTION hasNoBootBlks (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  136.     FUNCTION hasAccessCntl (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  137.     FUNCTION hasNoSysDir (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  138.     FUNCTION hasExtFSVol (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  139.     FUNCTION hasOpenDeny (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  140.     FUNCTION hasCopyFile (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  141.     FUNCTION hasMoveRename (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  142.     FUNCTION hasDesktopMgr (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  143.     FUNCTION hasShortName (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  144.     FUNCTION hasFolderLock (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  145.     FUNCTION hasPersonalAccessPrivileges (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  146.     FUNCTION hasUserGroupList (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  147.     FUNCTION hasCatSearch (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  148.     FUNCTION hasFileIDs (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  149.     FUNCTION hasBTreeMgr (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  150.     FUNCTION hasBlankAccessPrivileges (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  151.  
  152.  
  153. {***************************************************************************}
  154.  
  155.  
  156.     FUNCTION GetTempBuffer (buffReqSize: LONGINT;
  157.                                     VAR buffActSize: LONGINT): Ptr;
  158. {    Allocate a temporary copy or search buffer.
  159. {    The GetTempBuffer function allocates a temporary buffer for file system    }
  160. {    operations which is at least 1024 bytes (1K) and a multiple of            }
  161. {    1024 bytes.                                                                }
  162. {                                                                            }
  163. {    buffReqSize        input:    Size you'd like the buffer to be.                }
  164. {    buffActSize        output:    Size of buffer allocated.                        }
  165. {    function result    output:    Pointer to memory allocated or nil if no memory    }
  166. {                            was available. The caller is responsible for    }
  167. {                            disposing of this buffer with DisposePtr.        }
  168.  
  169.  
  170. {***************************************************************************}
  171.  
  172.  
  173.     FUNCTION DetermineVRefNum (pathname: StringPtr;
  174.                                     vRefNum: Integer;
  175.                                     VAR realVRefNum: Integer): OSErr;
  176. {    Use DetermineVRefNum to determine the volume reference number of a        }
  177. {    volume from a pathname, a volume specification, or a combination        }
  178. {    of the two.                                                                }
  179. {    WARNING: Volume names on the Macintosh are *not* unique -- Multiple        }
  180. {    mounted volumes can have the same name. For this reason, the use of a    }
  181. {    volume name or full pathname to identify a specific volume may not        }
  182. {    produce the results you expect.  If more than one volume has the same    }
  183. {    name and a volume name or full pathname is used, the File Manager        }
  184. {    currently uses the first volume it finds with a matching name in the    }
  185. {    volume queue.                                                            }
  186. {                                                                            }
  187. {    pathName    input:    Pointer to a full pathname or nil.  If you pass in    }
  188. {                        a partial pathname, it is ignored. A full pathname    }
  189. {                        to a volume must end with a colon character (:).    }
  190. {    vRefNum        input:    Volume specification (volume reference number,        }
  191. {                        working    directory number, drive number, or 0).        }
  192. {    realVRefNum    output:    The real volume reference number.                    }
  193.  
  194.  
  195. {***************************************************************************}
  196.  
  197.  
  198.     FUNCTION HGetVInfo (volReference: Integer;
  199.                                     volName: StringPtr;
  200.                                     VAR vRefNum: Integer;
  201.                                     VAR freeBytes: LongInt;
  202.                                     VAR totalBytes: LongInt): OSErr;
  203. {    The HGetVInfo function returns the name, volume reference number,        }
  204. {    available space (in bytes), and total space (in bytes) for the            }
  205. {    specified volume. You can specify the volume by providing its drive        }
  206. {    number, volume reference number, or 0 for the default volume.            }
  207. {    This routine is compatible with volumes up to 4 gigabytes.                }
  208. {                                                                            }
  209. {    volReference    input:    The drive number, volume reference number,        }
  210. {                            or 0 for the default volume.                    }
  211. {    volName            input:    A pointer to a buffer (minimum Str27) where        }
  212. {                            the volume name is to be returned or must        }
  213. {                            be nil.                                            }
  214. {                    output:    The volume name.                                }
  215. {    vRefNum            output:    The volume reference number.                    }
  216. {    freeBytes        output:    The number of free bytes on the volume.            }
  217. {                            freeBytes is an UNSIGNED long value.            }
  218. {    totalBytes        output:    The total number of bytes on the volume.        }
  219. {                            totalBytes is an UNSIGNED long value.            }
  220.  
  221.  
  222. {***************************************************************************}
  223.  
  224.  
  225.     FUNCTION CheckVolLock (pathname: StringPtr;
  226.                                     vRefNum: Integer): OSErr;
  227. {    Use CheckVolLock to determine if a volume is locked - either by         }
  228. {    hardware or by software. If CheckVolLock returns noErr, then the volume    }
  229. {    is not locked.                                                            }
  230. {                                                                            }
  231. {    pathName    input:    Pointer to a full pathname or nil.  If you pass in    }
  232. {                        a partial pathname, it is ignored. A full pathname    }
  233. {                        to a volume must end with a colon character (:).    }
  234. {    vRefNum        input:    Volume specification (volume reference number,        }
  235. {                        working    directory number, drive number, or 0).        }
  236.  
  237.  
  238. {***************************************************************************}
  239.  
  240.  
  241.     FUNCTION GetDriverName (driverRefNum: Integer;
  242.                                     VAR driverName: Str255): OSErr;
  243. {    Get a device driver's name.                                                }
  244. {    The GetDriverName function returns a device driver's name.                }
  245. {                                                                            }
  246. {    driverRefNum    input:    The driver reference number.                    }
  247. {    driverName        output:    The driver's name.                                }
  248.  
  249.  
  250. {***************************************************************************}
  251.  
  252.  
  253.     FUNCTION FindDrive (pathname: StringPtr;
  254.                                     vRefNum: Integer;
  255.                                     VAR driveQElementPtr: DrvQElPtr): OSErr;
  256. {    Find a volume's drive queue element in the drive queue.                    }
  257. {    The FindDrive function returns a pointer to a mounted volume's            }
  258. {    drive queue element.                                                    }
  259. {                                                                            }
  260. {    pathName            input:    Pointer to a full pathname or nil. If you    }
  261. {                                pass in a partial pathname, it is ignored.    }
  262. {                                A full pathname to a volume must end with    }
  263. {                                a colon character (:).                        }
  264. {    vRefNum                input:    Volume specification (volume reference        }
  265. {                                number, working directory number, drive        }
  266. {                                number, or 0).                                }
  267. {    driveQElementPtr    output:    Pointer to a volume's drive queue element    }
  268. {                                in the drive queue. DO NOT change the        }
  269. {                                DrvQEl.                                        }
  270.  
  271.  
  272. {***************************************************************************}
  273.  
  274.  
  275.     FUNCTION UnmountAndEject (pathname: StringPtr;
  276.                                     vRefNum: Integer): OSErr;
  277. {    Use UnmountAndEject to unmount and eject a volume. The volume is        }
  278. {    ejected only if it's ejectable and not already ejected.                    }
  279. {                                                                            }
  280. {    pathName    input:    Pointer to a full pathname or nil.  If you pass in  }
  281. {                        a partial pathname, it is ignored. A full pathname    }
  282. {                        to a volume must end with a colon character (:).    }
  283. {    vRefNum        input:    Volume specification (volume reference number,        }
  284. {                        workingdirectory number, drive number, or 0).        }
  285.  
  286.  
  287. {***************************************************************************}
  288.  
  289.  
  290.     FUNCTION OnLine (volumes: FSSpecPtr;
  291.                                     reqVolCount: Integer;
  292.                                     VAR actVolCount: Integer;
  293.                                     VAR volIndex: Integer): OSErr;
  294. {    Use OnLine to return the list of volumes currently mounted.                }
  295. {                                                                            }
  296. {    volumes        input:    Pointer to array of FSSpec where the volume list    }
  297. {                        is returned.                                        }
  298. {    reqVolCount    input:    Maximum number of volumes to return    (the number of    }
  299. {                        elements in the volumes array).                        }
  300. {    actVolCount    output: The number of volumes actually returned.            }
  301. {    volIndex    input:    The current volume index position. Set to 1 to        }
  302. {                        start with the first volume.                        }
  303. {                output:    The volume index position to get the next volume.    }
  304. {                        Pass this value the next time you call OnLine to    }
  305. {                        start where you left off.                            }
  306.  
  307.  
  308. {***************************************************************************}
  309.  
  310.  
  311.     FUNCTION GetDInfo (vRefNum: Integer;
  312.                                     dirID: LongInt;
  313.                                     name: StringPtr;
  314.                                     VAR fndrInfo: DInfo): OSErr;
  315. {    Use GetDInfo to get the finder information for a directory.                }
  316. {                                                                            }
  317. {    vRefNum            input:    Volume specification.                            }
  318. {    dirID            input:    Directory ID.                                    }
  319. {    name            input:    Pointer to object name, or nil when dirID        }
  320. {                            specifies a directory that's the object.        }
  321. {    fndrInfo        output:    If the object is a directory, then its DInfo.    }
  322.  
  323.  
  324. {***************************************************************************}
  325.  
  326.  
  327.     FUNCTION FSpGetDInfo ({CONST}VAR spec: FSSpec;
  328.                                     VAR fndrInfo: DInfo): OSErr;
  329. {    Use FSpGetDInfo to get the finder information for a directory.            }
  330. {                                                                            }
  331. {    spec        input:    An FSSpec record specifying the directory.            }
  332. {    fndrInfo    output:    If the object is a directory, then its DInfo.        }
  333.  
  334.  
  335. {***************************************************************************}
  336.  
  337.  
  338.     FUNCTION SetDInfo (vRefNum: Integer;
  339.                                     dirID: LongInt;
  340.                                     name: StringPtr;
  341.                                     fndrInfo: DInfo): OSErr;
  342. {    Use SetDInfo to Set the finder information for a directory.                }
  343. {                                                                            }
  344. {    vRefNum            input:    Volume specification.                            }
  345. {    dirID            input:    Directory ID.                                    }
  346. {    name            input:    Pointer to object name, or nil when dirID        }
  347. {                            specifies a directory that's the object.        }
  348. {    fndrInfo        output:    The DInfo.                                        }
  349.  
  350.  
  351. {***************************************************************************}
  352.  
  353.  
  354.     FUNCTION FSpSetDInfo ({CONST}VAR spec: FSSpec;
  355.                                     fndrInfo: DInfo): OSErr;
  356. {    Use FSpSetDInfo to set the finder information for a directory.            }
  357. {                                                                            }
  358. {    spec        input:    An FSSpec record specifying the directory.            }
  359. {    fndrInfo    input:    The DInfo.                                            }
  360.  
  361.  
  362. {***************************************************************************}
  363.  
  364.  
  365.     FUNCTION GetDirID (vRefNum: Integer;
  366.                                     dirID: LongInt;
  367.                                     name: StringPtr;
  368.                                     VAR theDirID: LongInt;
  369.                                     VAR isDirectory: Boolean): OSErr;
  370. {    Use GetDirID to get the directory ID number of the directory            }
  371. {    specified.  If a file is specified, then the parent                        }
  372. {    directory of the file is returned and isDirectory is false.  If            }
  373. {    a directory is specified, then that directory's ID number is            }
  374. {    returned and isDirectory is true.                                        }
  375. {    WARNING: Volume names on the Macintosh are *not* unique -- Multiple        }
  376. {    mounted volumes can have the same name. For this reason, the use of a    }
  377. {    volume name or full pathname to identify a specific volume may not        }
  378. {    produce the results you expect.  If more than one volume has the same    }
  379. {    name and a volume name or full pathname is used, the File Manager        }
  380. {    currently uses the first volume it finds with a matching name in the    }
  381. {    volume queue.                                                            }
  382. {                                                                            }
  383. {    vRefNum            input:    Volume specification.                            }
  384. {    dirID            input:    Directory ID.                                    }
  385. {    name            input:    Pointer to object name, or nil when dirID        }
  386. {                            specifies a directory that's the object.        }
  387. {    theDirID        output:    If the object is a file, then its parent        }
  388. {                            directory ID. If the object is a directory,        }
  389. {                            then its ID.                                    }
  390. {    isDirectory        output:    True if object is a directory; false if            }
  391. {                            object is a file.                                }
  392.  
  393.  
  394. {***************************************************************************}
  395.  
  396.  
  397.     FUNCTION DirIDFromFSSpec ({CONST}VAR spec: FSSpec;
  398.                                     VAR dirID: LongInt;
  399.                                     VAR isDirectory: Boolean): OSErr;
  400. {    Use DirIDFromFSSpec to get the directory ID number of the directory        }
  401. {    specified by spec. If spec is to a file, then the parent                }
  402. {    directory of the file is returned and isDirectory is false.  If            }
  403. {    spec is to a directory, then that directory's ID number is                }
  404. {    returned and isDirectory is true.                                        }
  405. {                                                                            }
  406. {    spec            input:    An FSSpec record specifying the directory.        }
  407. {    theDirID        output:    The directory ID.                                }
  408. {    isDirectory        output:    True if object is a directory; false if            }
  409. {                            object is a file.                                }
  410.  
  411.  
  412. {***************************************************************************}
  413.  
  414.  
  415.     FUNCTION GetDirName (vRefNum: Integer;
  416.                                     dirID: LongInt;
  417.                                     name: StringPtr): OSErr;
  418. {    Use GetDirName to get the name of a directory from its directory ID.    }
  419. {                                                                            }
  420. {    vRefNum        input:    Volume specification.                                }
  421. {    dirID        input:    Directory ID.                                        }
  422. {    name        output:    Points to a buffer (minimum Str63) where the        }
  423. {                        directory name is to be returned or must be nil.    }
  424.  
  425.  
  426. {***************************************************************************}
  427.  
  428.  
  429.     FUNCTION GetParentID (vRefNum: Integer;
  430.                                     dirID: LongInt;
  431.                                     name: StringPtr;
  432.                                     VAR parID: LongInt): OSErr;
  433. {    Use GetParentID to get the parent directory ID number of the specified    }
  434. {    object.                                                                    }
  435. {                                                                            }
  436. {    vRefNum        input:    Volume specification.                                }
  437. {    dirID        input:    Directory ID.                                        }
  438. {    name        input:    Pointer to object name, or nil when dirID specifies    }
  439. {                        a directory that's the object.                        }
  440. {    parID        output:    The parent directory ID of the specified object.    }
  441.  
  442.  
  443. {***************************************************************************}
  444.  
  445.  
  446.     FUNCTION GetFilenameFromPathname (pathname: Str255;
  447.                                     VAR filename: Str255): OSErr;
  448. {    Use GetFilenameFromPathname to get the file (or directory) name from    }
  449. {    the end of a full or partial pathname. Returns notAFileErr if the        }
  450. {    pathname is nil, the pathname is empty, or the pathname cannot refer to    }
  451. {    a filename (with a noErr result, the pathname could still refer to a    }
  452. {    directory). GetFilenameFromPathname is used by GetObjectLocation.        }
  453. {                                                                            }
  454. {    pathname    input:    A full or partial pathname.                            }
  455. {    filename    output:    The file (or directory) name.                        }
  456.  
  457.  
  458. {***************************************************************************}
  459.  
  460.  
  461.     FUNCTION GetObjectLocation (vRefNum: Integer;
  462.                                     dirID: LongInt;
  463.                                     pathname: StringPtr;
  464.                                     VAR realVRefNum: Integer;
  465.                                     VAR realParID: LongInt;
  466.                                     VAR realName: Str255;
  467.                                     VAR isDirectory: Boolean): OSErr;
  468. {    Use GetObjectLocation to get a file system object's location - that is,    }
  469. {    its real volume reference number, real parent directory ID, and name.    }
  470. {    While we're at it, determine if the object is a file or directory.        }
  471. {    If GetObjectLocation returns fnfErr, then the location information        }
  472. {    returned is valid, but it describes an object that doesn't exist.        }
  473. {    You can use the location information for another operation, such as        }
  474. {    creating a file or directory.                                            }
  475. {                                                                            }
  476. {    vRefNum        input:    Volume specification.                                }
  477. {    dirID        input:    Directory ID.                                        }
  478. {    pathname    input:    Pointer to object name, or nil when dirID specifies    }
  479. {                        a directory that's the object.                        }
  480. {    realVRefNum    output:    The real volume reference number.                    }
  481. {    realParID    output:    The parent directory ID of the specified object.    }
  482. {    realName    output:    The name of the specified object (the case of the    }
  483. {                        object name may not be the same as the object's        }
  484. {                        catalog entry on disk - since the Macintosh file    }
  485. {                        system is not case sensitive, it shouldn't matter).    }
  486. {    isDirectory    output:    True if object is a directory; false if object        }
  487. {                        is a file.                                            }
  488.  
  489.  
  490. {***************************************************************************}
  491.  
  492.  
  493.     FUNCTION GetDirItems (vRefNum: Integer;
  494.                                     dirID: LongInt;
  495.                                     name: StringPtr;
  496.                                     getFiles: Boolean;
  497.                                     getDirectories: Boolean;
  498.                                     items: FSSpecPtr;
  499.                                     reqItemCount: Integer;
  500.                                     VAR actItemCount: Integer;
  501.                                     VAR itemIndex: Integer): OSErr;
  502. {    Use GetDirItems to return a list of items in a directory.                }
  503. {                                                                            }
  504. {    vRefNum            input:    Volume specification.                            }
  505. {    dirID            input:    Directory ID.                                    }
  506. {    name            input:    Pointer to object name, or nil when dirID        }
  507. {                            specifies a directory that's the object.        }
  508. {    getFiles        input:    Pass true to have files added to the items list.}
  509. {    getDirectories    input:    Pass true to have directories added to the        }
  510. {                            items list.                                        }
  511. {    items            input:    Pointer to array of FSSpec where the item list    }
  512. {                            is returned.                                    }
  513. {    reqItemCount    input:    Maximum number of items to return (the number    }
  514. {                            of elements in the items array).                }
  515. {    actItemCount    output: The number of volumes actually returned.        }
  516. {    itemIndex        input:    The current item index position. Set to 1 to    }
  517. {                            start with the first item in the directory.        }
  518. {                    output:    The item index position to get the next item.    }
  519. {                            Pass this value the next time you call            }
  520. {                            GetDirItems to start where you left off.        }
  521.  
  522.  
  523. {***************************************************************************}
  524.  
  525.  
  526.     FUNCTION DeleteDirectoryContents (vRefNum: Integer;
  527.                                     dirID: LongInt;
  528.                                     name: StringPtr): OSErr;
  529. {    The DeleteDirectoryContents function deletes the contents of a            }
  530. {    directory. All files and subdirectories in the specified directory are    }
  531. {    deleted. If a locked file or directory is encountered, it is unlocked    }
  532. {    and then deleted.  If any unexpected errors are encountered,            }
  533. {    DeleteDirectoryContents quits and returns to the caller.                }
  534. {                                                                            }
  535. {    vRefNum    input:    Volume specification.                                    }
  536. {    dirID    input:    Directory ID.                                            }
  537. {    name    input:    Pointer to directory name, or nil when dirID specifies    }
  538. {                    a directory that's the object.                            }
  539.  
  540.  
  541. {***************************************************************************}
  542.  
  543.  
  544.     FUNCTION DeleteDirectory (vRefNum: Integer;
  545.                                     dirID: LongInt;
  546.                                     name: StringPtr): OSErr;
  547. {    The DeleteDirectory function deletes a directory and its contents.        }
  548. {    All files and subdirectories in the specified directory are deleted.    }
  549. {    If a locked file or directory is encountered, it is unlocked and then    }
  550. {    deleted.  After deleting the directories contents, the directory is        }
  551. {    deleted. If any unexpected errors are encountered, DeleteDirectory        }
  552. {    quits and returns to the caller.                                        }
  553. {                                                                            }
  554. {    vRefNum    input:    Volume specification.                                    }
  555. {    dirID    input:    Directory ID.                                            }
  556. {    name    input:    Pointer to directory name, or nil when dirID specifies    }
  557. {                    a directory that's the object.                            }
  558.  
  559.  
  560. {***************************************************************************}
  561.  
  562.  
  563.     FUNCTION CheckObjectLock (vRefNum: Integer;
  564.                                     dirID: LongInt;
  565.                                     name: StringPtr): OSErr;
  566. {    Use CheckObjectLock to determine if a file or directory is locked.        }
  567. {    If CheckObjectLock returns noErr, then the file or directory            }
  568. {    is not locked.                                                            }
  569. {                                                                            }
  570. {    vRefNum    input:    Volume specification.                                    }
  571. {    dirID    input:    Directory ID.                                            }
  572. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  573. {                    a directory that's the object.                            }
  574.  
  575.  
  576. {***************************************************************************}
  577.  
  578.     FUNCTION FSpCheckObjectLock ({CONST}VAR spec: FSSpec): OSErr;
  579. {    Use FSpCheckObjectLock to determine if a file or directory is locked.    }
  580. {    If FSpCheckObjectLock returns noErr, then the file or directory            }
  581. {    is not locked.                                                            }
  582. {                                                                            }
  583. {    spec    input:    An FSSpec record specifying the object.                    }
  584.  
  585.  
  586. {***************************************************************************}
  587.  
  588.  
  589.     FUNCTION GetFileSize (vRefNum: Integer;
  590.                                     dirID: LongInt;
  591.                                     fileName: Str255;
  592.                                     VAR dataSize: LONGINT;
  593.                                     VAR rsrcSize: LONGINT): OSErr;
  594. {    Get the logical sizes of a file's forks.                                }
  595. {    The GetFileSize function returns the logical size of a file's            }
  596. {    data and resource fork.                                                    }
  597. {                                                                            }
  598. {    vRefNum        input:    Volume specification.                                }
  599. {    dirID        input:    Directory ID.                                        }
  600. {    name        input:    The name of the file.                                }
  601. {    dataSize    output:    The number of bytes in the file's data fork.        }
  602. {    rsrcSize    output:    The number of bytes in the file's resource fork.    }
  603.  
  604.  
  605. {***************************************************************************}
  606.  
  607.  
  608.     FUNCTION FSpGetFileSize ({CONST}VAR spec: FSSpec;
  609.                                     VAR dataSize: LONGINT;
  610.                                     VAR rsrcSize: LONGINT): OSErr;
  611. {    Get the logical sizes of a file's forks.                                }
  612. {    The FSpGetFileSize function returns the logical size of a file's        }
  613. {    data and resource fork.                                                    }
  614. {                                                                            }
  615. {    spec        input:    An FSSpec record specifying the file.                }
  616. {    dataSize    output:    The number of bytes in the file's data fork.        }
  617. {    rsrcSize    output:    The number of bytes in the file's resource fork.    }
  618.  
  619.  
  620. {***************************************************************************}
  621.  
  622.  
  623.     FUNCTION BumpDate (vRefNum: Integer;
  624.                                     dirID: LongInt;
  625.                                     name: StringPtr): OSErr;
  626. {    Use BumpDate to change the modification date of a file or directory to    }
  627. {    the current date/time.  If the modification date is already equal to    }
  628. {    the current date/time, then add one second to the modification date.    }
  629. {                                                                            }
  630. {    vRefNum    input:    Volume specification.                                    }
  631. {    dirID    input:    Directory ID.                                            }
  632. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  633. {                    a directory that's the object.                            }
  634.  
  635.  
  636. {***************************************************************************}
  637.  
  638.     FUNCTION FSpBumpDate ({CONST}VAR spec: FSSpec): OSErr;
  639. {    Use FSpBumpDate to change the modification date of a file or directory    }
  640. {    to the current date/time.  If the modification date is already equal    }
  641. {    to the current date/time, then add one second to the modification date.    }
  642. {                                                                            }
  643. {    spec    input:    An FSSpec record specifying the object.                    }
  644.  
  645.  
  646. {***************************************************************************}
  647.  
  648.  
  649.     FUNCTION ChangeCreatorType (vRefNum: Integer;
  650.                                     dirID: LongInt;
  651.                                     name: Str255;
  652.                                     creator: OSType;
  653.                                     fileType: OSType): OSErr;
  654. {    Use ChangeCreatorType to change the creator or file type of a file.        }
  655. {                                                                            }
  656. {    vRefNum        input:    Volume specification.                                }
  657. {    dirID        input:    Directory ID.                                        }
  658. {    name        input:    The name of the file.                                }
  659. {    creator        input:    The new creator type or 0x00000000 to leave            }
  660. {                        the creator type alone.                                }
  661. {    fileType    input:    The new file type or 0x00000000 to leave the        }
  662. {                        file type alone.                                    }
  663.  
  664.  
  665. {***************************************************************************}
  666.  
  667.  
  668.     FUNCTION FSpChangeCreatorType ({CONST}VAR spec: FSSpec;
  669.                                     creator: OSType;
  670.                                     fileType: OSType): OSErr;
  671. {    Use FSpChangeCreatorType to change the creator or file type of a file.    }
  672. {                                                                            }
  673. {    spec        input:    An FSSpec record specifying the file.                }
  674. {    creator        input:    The new creator type or 0x00000000 to leave            }
  675. {                        the creator type alone.                                }
  676. {    fileType    input:    The new file type or 0x00000000 to leave the        }
  677. {                        file type alone.                                    }
  678.  
  679.  
  680. {***************************************************************************}
  681.  
  682.  
  683.     FUNCTION ChangeFDFlags (vRefNum: Integer;
  684.                                     dirID: LongInt;
  685.                                     name: StringPtr;
  686.                                     setBits: Boolean;
  687.                                     flagBits: Integer): OSErr;
  688. {    Use ChangeFDFlags to set or clear Finder Flag bits in the fdFlags field    }
  689. {    of a file or directory's FInfo record.                                    }
  690. {                                                                            }
  691. {    vRefNum        input:    Volume specification.                                }
  692. {    dirID        input:    Directory ID.                                        }
  693. {    name        input:    Pointer to object name, or nil when dirID specifies    }
  694. {                        a directory that's the object.                        }
  695. {    setBits        input:    If true, then set the bits specified in flagBits.    }
  696. {                        If false, then clear the bits specified in flagBits.}
  697. {    flagBits    input:    The flagBits parameter specifies which Finder Flag    }
  698. {                        bits to set or clear. If a bit in flagBits is set,    }
  699. {                        then the same bit in fdFlags is either set or        }
  700. {                        cleared depending on the state of the setBits        }
  701. {                        parameter.                                            }
  702.  
  703.  
  704. {***************************************************************************}
  705.  
  706.  
  707.     FUNCTION FSpChangeFDFlags ({CONST}VAR spec: FSSpec;
  708.                                     setBits: Boolean;
  709.                                     flagBits: Integer): OSErr;
  710. {    Use FSpChangeFDFlags to set or clear Finder Flag bits in the fdFlags    }
  711. {    field of a file or directory's FInfo record.                            }
  712. {                                                                            }
  713. {    spec        input:    An FSSpec record specifying the object.                }
  714. {    setBits        input:    If true, then set the bits specified in flagBits.    }
  715. {                        If false, then clear the bits specified in flagBits.}
  716. {    flagBits    input:    The flagBits parameter specifies which Finder Flag    }
  717. {                        bits to set or clear. If a bit in flagBits is set,    }
  718. {                        then the same bit in fdFlags is either set or        }
  719. {                        cleared depending on the state of the setBits        }
  720. {                        parameter.                                            }
  721.  
  722.  
  723. {***************************************************************************}
  724.  
  725.  
  726.     FUNCTION SetIsInvisible (vRefNum: Integer;
  727.                                     dirID: LongInt;
  728.                                     name: StringPtr): OSErr;
  729. {    Use SetIsInvisible to set the invisible bit in the fdFlags word of the    }
  730. {    specified file or directory's finder information.                        }
  731. {                                                                            }
  732. {    vRefNum    input:    Volume specification.                                    }
  733. {    dirID    input:    Directory ID.                                            }
  734. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  735. {                    a directory that's the object.                            }
  736.  
  737.  
  738. {***************************************************************************}
  739.  
  740.  
  741.     FUNCTION FSpSetIsInvisible ({CONST}VAR spec: FSSpec): OSErr;
  742. {    Use FSpSetIsInvisible to set the invisible bit in the fdFlags word of    }
  743. {    the specified file or directory's finder information.                    }
  744. {                                                                            }
  745. {    spec    input:    An FSSpec record specifying the object.                    }
  746.  
  747.  
  748. {***************************************************************************}
  749.  
  750.  
  751.     FUNCTION ClearIsInvisible (vRefNum: Integer;
  752.                                     dirID: LongInt;
  753.                                     name: StringPtr): OSErr;
  754. {    Use ClearIsInvisible to clear the invisible bit in the fdFlags word of    }
  755. {    the specified file or directory's finder information.                    }
  756. {                                                                            }
  757. {    vRefNum    input:    Volume specification.                                    }
  758. {    dirID    input:    Directory ID.                                            }
  759. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  760. {                    a directory that's the object.                            }
  761.  
  762.  
  763. {***************************************************************************}
  764.  
  765.  
  766.     FUNCTION FSpClearIsInvisible ({CONST}VAR spec: FSSpec): OSErr;
  767. {    Use FSpClearIsInvisible to clear the invisible bit in the fdFlags word    }
  768. {    of the specified file or directory's finder information.                }
  769. {                                                                            }
  770. {    spec    input:    An FSSpec record specifying the object.                    }
  771.  
  772.  
  773. {***************************************************************************}
  774.  
  775.  
  776.     FUNCTION SetNameLocked (vRefNum: Integer;
  777.                                     dirID: LongInt;
  778.                                     name: StringPtr): OSErr;
  779. {    Use SetNameLocked to set the nameLocked bit in the fdFlags word of the    }
  780. {    specified file or directory's finder information.                        }
  781. {                                                                            }
  782. {    vRefNum    input:    Volume specification.                                    }
  783. {    dirID    input:    Directory ID.                                            }
  784. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  785. {                    a directory that's the object.                            }
  786.  
  787.  
  788. {***************************************************************************}
  789.  
  790.  
  791.     FUNCTION FSpSetNameLocked ({CONST}VAR spec: FSSpec): OSErr;
  792. {    Use FSpSetNameLocked to set the nameLocked bit in the fdFlags word of    }
  793. {    the specified file or directory's finder information.                    }
  794. {                                                                            }
  795. {    spec    input:    An FSSpec record specifying the object.                    }
  796.  
  797.  
  798. {***************************************************************************}
  799.  
  800.  
  801.     FUNCTION ClearNameLocked (vRefNum: Integer;
  802.                                     dirID: LongInt;
  803.                                     name: StringPtr): OSErr;
  804. {    Use ClearNameLocked to clear the nameLocked bit in the fdFlags word of    }
  805. {    the specified file or directory's finder information.                    }
  806. {                                                                            }
  807. {    vRefNum    input:    Volume specification.                                    }
  808. {    dirID    input:    Directory ID.                                            }
  809. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  810. {                    a directory that's the object.                            }
  811.  
  812.  
  813. {***************************************************************************}
  814.  
  815.  
  816.     FUNCTION FSpClearNameLocked ({CONST}VAR spec: FSSpec): OSErr;
  817. {    Use FSpClearNameLocked to clear the nameLocked bit in the fdFlags word    }
  818. {    of the specified file or directory's finder information.                }
  819. {                                                                            }
  820. {    spec    input:    An FSSpec record specifying the object.                    }
  821.  
  822.  
  823. {***************************************************************************}
  824.  
  825.  
  826.     FUNCTION SetIsStationery (vRefNum: Integer;
  827.                                     dirID: LongInt;
  828.                                     name: Str255): OSErr;
  829. {    Use SetIsStationery to set the isStationery bit in the fdFlags word        }
  830. {    of the specified file or directory's finder information.                }
  831. {                                                                            }
  832. {    vRefNum    input:    Volume specification.                                    }
  833. {    dirID    input:    Directory ID.                                            }
  834. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  835. {                    a directory that's the object.                            }
  836.  
  837.  
  838. {***************************************************************************}
  839.  
  840.  
  841.     FUNCTION FSpSetIsStationery ({CONST}VAR spec: FSSpec): OSErr;
  842. {    Use FSpSetIsStationery to set the isStationery bit in the fdFlags        }
  843. {    word of the specified file or directory's finder information.            }
  844. {                                                                            }
  845. {    spec    input:    An FSSpec record specifying the object.                    }
  846.  
  847.  
  848. {***************************************************************************}
  849.  
  850.  
  851.     FUNCTION ClearIsStationery (vRefNum: Integer;
  852.                                     dirID: LongInt;
  853.                                     name: Str255): OSErr;
  854. {    Use ClearIsStationery to clear the isStationery bit in the fdFlags        }
  855. {    word of the specified file or directory's finder information.            }
  856. {                                                                            }
  857. {    vRefNum    input:    Volume specification.                                    }
  858. {    dirID    input:    Directory ID.                                            }
  859. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  860. {                    a directory that's the object.                            }
  861.  
  862.  
  863. {***************************************************************************}
  864.  
  865.  
  866.     FUNCTION FSpClearIsStationery ({CONST}VAR spec: FSSpec): OSErr;
  867. {    Use FSpClearIsStationery to clear the isStationery bit in the fdFlags    }
  868. {    word of the specified file or directory's finder information.            }
  869. {                                                                            }
  870. {    spec    input:    An FSSpec record specifying the object.                    }
  871.  
  872.  
  873. {***************************************************************************}
  874.  
  875.  
  876.     FUNCTION SetHasCustomIcon (vRefNum: Integer;
  877.                                     dirID: LongInt;
  878.                                     name: StringPtr): OSErr;
  879. {    Use SetHasCustomIcon to set the hasCustomIcon bit in the fdFlags word    }
  880. {    of the specified file or directory's finder information.                }
  881. {                                                                            }
  882. {    vRefNum    input:    Volume specification.                                    }
  883. {    dirID    input:    Directory ID.                                            }
  884. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  885. {                    a directory that's the object.                            }
  886.  
  887.  
  888. {***************************************************************************}
  889.  
  890.  
  891.     FUNCTION FSpSetHasCustomIcon ({CONST}VAR spec: FSSpec): OSErr;
  892. {    Use FSpSetHasCustomIcon to set the hasCustomIcon bit in the fdFlags        }
  893. {    word of the specified file or directory's finder information.            }
  894. {                                                                            }
  895. {    spec    input:    An FSSpec record specifying the object.                    }
  896.  
  897.  
  898. {***************************************************************************}
  899.  
  900.  
  901.     FUNCTION ClearHasCustomIcon (vRefNum: Integer;
  902.                                     dirID: LongInt;
  903.                                     name: StringPtr): OSErr;
  904. {    Use ClearHasCustomIcon to clear the hasCustomIcon bit in the fdFlags    }
  905. {    word of the specified file or directory's finder information.            }
  906. {                                                                            }
  907. {    vRefNum    input:    Volume specification.                                    }
  908. {    dirID    input:    Directory ID.                                            }
  909. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  910. {                    a directory that's the object.                            }
  911.  
  912.  
  913. {***************************************************************************}
  914.  
  915.  
  916.     FUNCTION FSpClearHasCustomIcon ({CONST}VAR spec: FSSpec): OSErr;
  917. {    Use FSpClearHasCustomIcon to clear the hasCustomIcon bit in the fdFlags    }
  918. {    word of the specified file or directory's finder information.            }
  919. {                                                                            }
  920. {    spec    input:    An FSSpec record specifying the object.                    }
  921.  
  922.  
  923. {***************************************************************************}
  924.  
  925.  
  926.     FUNCTION ClearHasBeenInited (vRefNum: Integer;
  927.                                     dirID: LongInt;
  928.                                     name: StringPtr): OSErr;
  929. {    Use ClearHasBeenInited to clear the hasBeenInited bit in the fdFlags    }
  930. {    word of the specified file or directory's finder information.            }
  931. {                                                                            }
  932. {    vRefNum    input:    Volume specification.                                    }
  933. {    dirID    input:    Directory ID.                                            }
  934. {    name    input:    Pointer to object name, or nil when dirID specifies        }
  935. {                    a directory that's the object.                            }
  936.  
  937.  
  938. {***************************************************************************}
  939.  
  940.     FUNCTION FSpClearHasBeenInited ({CONST}VAR spec: FSSpec): OSErr;
  941. {    Use FSpClearHasBeenInited to clear the hasBeenInited bit in the fdFlags    }
  942. {    word of the specified file or directory's finder information.            }
  943. {                                                                            }
  944. {    spec    input:    An FSSpec record specifying the object.                    }
  945.  
  946.  
  947. {***************************************************************************}
  948.  
  949.  
  950.     FUNCTION CopyFileMgrAttributes (srcVRefNum: Integer;
  951.                                     srcDirID: LongInt;
  952.                                     srcName: StringPtr;
  953.                                     dstVRefNum: Integer;
  954.                                     dstDirID: LongInt;
  955.                                     dstName: StringPtr;
  956.                                     copyLockBit: Boolean): OSErr;
  957. {    Use CopyFileMgrAttributes to copy all File Manager attributes from the    }
  958. {    source file or directory to the destination file or directory.            }
  959. {    If copyLockBit is true, then set the locked state of the destination    }
  960. {    to match the source.                                                    }
  961. {                                                                            }
  962. {    srcVRefNum    input:    Source volume specification.                        }
  963. {    srcDirID    input:    Source directory ID.                                }
  964. {    srcName        input:    Pointer to source object name, or nil when            }
  965. {                        srcDirID specifies a directory that's the object.    }
  966. {    dstVRefNum    input:    Destination volume specification.                    }
  967. {    dstDirID    input:    Destination directory ID.                            }
  968. {    dstName        input:    Pointer to destination object name, or nil when        }
  969. {                        dstDirID specifies a directory that's the object.    }
  970. {    copyLockBit    input:    If true, set the locked state of the destination    }
  971. {                        to match the source.                                }
  972.  
  973.  
  974. {***************************************************************************}
  975.  
  976.  
  977.     FUNCTION FSpCopyFileMgrAttributes ({CONST}VAR srcSpec: FSSpec;
  978.                                     {CONST}VAR dstSpec: FSSpec;
  979.                                     copyLockBit: Boolean): OSErr;
  980. {    Use FSpCopyFileMgrAttributes to copy all File Manager attributes from    }
  981. {    the source file or directory to the destination file or directory.        }
  982. {    If copyLockBit is true, then set the locked state of the destination    }
  983. {    to match the source.                                                    }
  984. {                                                                            }
  985. {    srcSpec        input:    An FSSpec record specifying the source object.        }
  986. {    dstSpec        input:    An FSSpec record specifying the destination object.    }
  987. {    copyLockBit    input:    If true, set the locked state of the destination    }
  988. {                        to match the source.                                }
  989.  
  990.  
  991. {***************************************************************************}
  992.  
  993.  
  994.     FUNCTION HOpenAware (vRefNum: Integer;
  995.                                     dirID: LongInt;
  996.                                     fileName: Str255;
  997.                                     denyModes: Integer;
  998.                                     VAR refNum: Integer): OSErr;
  999. {    Use HOpenAware to open the data fork of a file using deny mode            }
  1000. {    permissions instead the normal File Manager permissions.  If OpenDeny    }
  1001. {    is not available, then HOpenAware translates the deny modes to the        }
  1002. {    closest File Manager permissions and tries to open the file with        }
  1003. {    OpenDF first, and then Open if OpenDF isn't available. By using            }
  1004. {    HOpenAware with deny mode permissions, a program can be "AppleShare        }
  1005. {    aware" and fall back on the standard File Manager open calls            }
  1006. {    automatically.                                                            }
  1007. {                                                                            }
  1008. {    vRefNum        input:    Volume specification.                                }
  1009. {    dirID        input:    Directory ID.                                        }
  1010. {    fileName    input:    The name of the file.                                }
  1011. {    denyModes    input:    The deny modes access under which to open the file.    }
  1012. {    refNum        output:    The file reference number of the opened file.        }
  1013.  
  1014.  
  1015. {***************************************************************************}
  1016.  
  1017.  
  1018.     FUNCTION FSpOpenAware ({CONST}VAR spec: FSSpec;
  1019.                                     denyModes: Integer;
  1020.                                     VAR refNum: Integer): OSErr;
  1021. {    Use FSpOpenAware to open the data fork of a file using deny mode        }
  1022. {    permissions instead the normal File Manager permissions.  If OpenDeny    }
  1023. {    is not available, then FSpOpenAware translates the deny modes to the    }
  1024. {    closest File Manager permissions and tries to open the file with        }
  1025. {    OpenDF first, and then Open if OpenDF isn't available. By using            }
  1026. {    FSpOpenAware with deny mode permissions, a program can be "AppleShare    }
  1027. {    aware" and fall back on the standard File Manager open calls            }
  1028. {    automatically.                                                            }
  1029. {                                                                            }
  1030. {    spec        input:    An FSSpec record specifying the file.                }
  1031. {    denyModes    input:    The deny modes access under which to open the file.    }
  1032. {    refNum        output:    The file reference number of the opened file.        }
  1033.  
  1034.  
  1035. {***************************************************************************}
  1036.  
  1037.  
  1038.     FUNCTION HOpenRFAware (vRefNum: Integer;
  1039.                                     dirID: LongInt;
  1040.                                     fileName: Str255;
  1041.                                     denyModes: Integer;
  1042.                                     VAR refNum: Integer): OSErr;
  1043. {    Use HOpenRFAware to open the resource fork of a file using deny mode    }
  1044. {    permissions instead the normal File Manager permissions.  If OpenRFDeny    }
  1045. {    is not available, then HOpenRFAware translates the deny modes to the    }
  1046. {    closest File Manager permissions and tries to open the file with        }
  1047. {    OpenRF. By using HOpenRFAware with deny mode permissions, a program        }
  1048. {    can be "AppleShare aware" and fall back on the standard File Manager    }
  1049. {    open calls automatically.                                                }
  1050. {                                                                            }
  1051. {    vRefNum        input:    Volume specification.                                }
  1052. {    dirID        input:    Directory ID.                                        }
  1053. {    fileName    input:    The name of the file.                                }
  1054. {    denyModes    input:    The deny modes access under which to open the file.    }
  1055. {    refNum        output:    The file reference number of the opened file.        }
  1056.  
  1057.  
  1058. {***************************************************************************}
  1059.  
  1060.  
  1061.     FUNCTION FSpOpenRFAware ({CONST}VAR spec: FSSpec;
  1062.                                     denyModes: Integer;
  1063.                                     VAR refNum: Integer): OSErr;
  1064. {    Use FSpOpenRFAware to open the resource fork of a file using deny mode    }
  1065. {    permissions instead the normal File Manager permissions.  If OpenRFDeny    }
  1066. {    is not available, then FSpOpenRFAware translates the deny modes to the    }
  1067. {    closest File Manager permissions and tries to open the file with        }
  1068. {    OpenRF. By using FSpOpenRFAware with deny mode permissions, a program    }
  1069. {    can be "AppleShare aware" and fall back on the standard File Manager    }
  1070. {    open calls automatically.                                                }
  1071. {                                                                            }
  1072. {    spec        input:    An FSSpec record specifying the file.                }
  1073. {    denyModes    input:    The deny modes access under which to open the file.    }
  1074. {    refNum        output:    The file reference number of the opened file.        }
  1075.  
  1076.  
  1077. {***************************************************************************}
  1078.  
  1079.  
  1080.     FUNCTION FSReadNoCache (refNum: Integer;
  1081.                                     VAR count: LongInt;
  1082.                                     buffPtr: Ptr): OSErr;
  1083. {    Use FSReadNoCache to read any number of bytes from an open file while    }
  1084. {    asking the file system to bypass its cache mechanism.                    }
  1085. {                                                                            }
  1086. {    refNum    input:    The file reference number of an open file.                }
  1087. {    count    input:    The number of bytes to read.                            }
  1088. {            output:    The number of bytes actually read.                        }
  1089. {    buffPtr    input:    A pointer to the data buffer into which the bytes are    }
  1090. {                    to be read.                                                }
  1091.  
  1092.  
  1093. {***************************************************************************}
  1094.  
  1095.  
  1096.     FUNCTION FSWriteNoCache (refNum: Integer;
  1097.                                     VAR count: LongInt;
  1098.                                     buffPtr: Ptr): OSErr;
  1099. {    Use FSReadNoCache to write any number of bytes to an open file while    }
  1100. {    asking the file system to bypass its cache mechanism.                    }
  1101. {                                                                            }
  1102. {    refNum    input:    The file reference number of an open file.                }
  1103. {    count    input:    The number of bytes to write to the file.                }
  1104. {            output:    The number of bytes actually written.                    }
  1105. {    buffPtr    input:    A pointer to the data buffer from which the bytes are    }
  1106. {                    to be written.                                            }
  1107.  
  1108.  
  1109. {***************************************************************************}
  1110.  
  1111.  
  1112.     FUNCTION FSWriteVerify (refNum: Integer;
  1113.                                     VAR count: LongInt;
  1114.                                     buffPtr: Ptr): OSErr;
  1115. {    Write any number of bytes to an open file and then verify the data was    }
  1116. {    written.                                                                }
  1117. {    The FSWriteVerify function writes any number of bytes to an open file    }
  1118. {    and then verifies that the data was actually written to the device.        }
  1119. {                                                                            }
  1120. {    refNum    input:    The file reference number of an open file.                }
  1121. {    count    input:    The number of bytes to write to the file.                }
  1122. {            output:    The number of bytes actually written.                    }
  1123. {    buffPtr    input:    A pointer to the data buffer from which the bytes are    }
  1124. {                    to be written.                                            }
  1125.  
  1126.  
  1127. {***************************************************************************}
  1128.  
  1129.  
  1130.     FUNCTION CopyFork (srcRefNum: Integer;
  1131.                                     dstRefNum: Integer;
  1132.                                     copyBufferPtr: Ptr;
  1133.                                     copyBufferSize: LongInt): OSErr;
  1134. {    Use CopyFork to copy all data from the source fork to the destination    }
  1135. {    fork of open file forks and makes sure the destination EOF is equal        }
  1136. {    to the source EOF.                                                        }
  1137. {                                                                            }
  1138. {    srcRefNum        input:    The source file reference number.                }
  1139. {    dstRefNum        input:    The destination file reference number.            }
  1140. {    copyBufferPtr    input:    Pointer to buffer to use during copy. The        }
  1141. {                            buffer should be at least 512-bytes minimum.    }
  1142. {                            The larger the buffer, the faster the copy.        }
  1143. {    copyBufferSize    input:    The size of the copy buffer.                    }
  1144.  
  1145.  
  1146. {***************************************************************************}
  1147.  
  1148.  
  1149.     FUNCTION GetFileLocation (refNum: Integer;
  1150.                                     VAR vRefNum: Integer;
  1151.                                     VAR dirID: LongInt;
  1152.                                     fileName: StringPtr): OSErr;
  1153. {    Use GetFileLocation to get the location (volume reference number,        }
  1154. {    directory ID, and fileName) of an open file.                            }
  1155. {                                                                            }
  1156. {    refNum        input:    The file reference number of an open file.            }
  1157. {    vRefNum        output:    The volume reference number.                        }
  1158. {    dirID        output:    The parent directory ID.                            }
  1159. {    fileName    input:    Points to a buffer (minimum Str63) where the        }
  1160. {                        filename is to be returned or must be nil.            }
  1161. {                output:    The filename.                                        }
  1162.  
  1163.  
  1164. {***************************************************************************}
  1165.  
  1166.  
  1167.     FUNCTION FSpGetFileLocation (refNum: Integer;
  1168.                                     VAR spec: FSSpec): OSErr;
  1169. {    Use FSpGetFileLocation to get the location of an open file in an        }
  1170. {    FSSpec record.                                                            }
  1171. {                                                                            }
  1172. {    refNum        input:    The file reference number of an open file.            }
  1173. {    spec        output:    FSSpec record containing the file name and location.}
  1174.  
  1175.  
  1176. {***************************************************************************}
  1177.  
  1178.  
  1179.     FUNCTION CopyDirectoryAccess (srcVRefNum: Integer;
  1180.                                     srcDirID: LongInt;
  1181.                                     srcName: StringPtr;
  1182.                                     dstVRefNum: Integer;
  1183.                                     dstDirID: LongInt;
  1184.                                     dstName: StringPtr): OSErr;
  1185. {    Use CopyDirectoryAccess to copy the AFP directory access privileges        }
  1186. {    from one directory to another. Both directories must be on the same        }
  1187. {    file server, but not necessarily on the same server volume.                }
  1188. {                                                                            }
  1189. {    srcVRefNum    input:    Source volume specification.                        }
  1190. {    srcDirID    input:    Source directory ID.                                }
  1191. {    srcName        input:    Pointer to source directory name, or nil when        }
  1192. {                        srcDirID specifies the directory.                    }
  1193. {    dstVRefNum    input:    Destination volume specification.                    }
  1194. {    dstDirID    input:    Destination directory ID.                            }
  1195. {    dstName        input:    Pointer to destination directory name, or nil when    }
  1196. {                        dstDirID specifies the directory.                    }
  1197.  
  1198.  
  1199. {***************************************************************************}
  1200.  
  1201.  
  1202.     FUNCTION FSpCopyDirectoryAccess ({CONST}VAR srcSpec: FSSpec;
  1203.                                     {CONST}VAR dstSpec: FSSpec): OSErr;
  1204. {    Use FSpCopyDirectoryAccess to copy the AFP directory access privileges    }
  1205. {    from one directory to another. Both directories must be on the same        }
  1206. {    file server, but not necessarily on the same server volume.                }
  1207. {                                                                            }
  1208. {    srcSpec        input:    An FSSpec record specifying the source directory.    }
  1209. {    dstSpec        input:    An FSSpec record specifying the destination            }
  1210. {                        directory.                                            }
  1211.  
  1212.  
  1213. {***************************************************************************}
  1214.  
  1215.  
  1216.     FUNCTION HMoveRenameCompat (vRefNum: Integer;
  1217.                                     srcDirID: LongInt;
  1218.                                     srcName: Str255;
  1219.                                     dstDirID: LongInt;
  1220.                                     dstpathName: StringPtr;
  1221.                                     copyName: StringPtr): OSErr;
  1222. {    Use HMoveRenameCompat to move a file or directory and optionally to        }
  1223. {    rename it.  The source and destination locations must be on the same    }
  1224. {    volume. This routine works even if the volume doesn't support            }
  1225. {    MoveRename.                                                                }
  1226. {                                                                            }
  1227. {    vRefNum        input:    Volume specification.                                }
  1228. {    srcDirID    input:    Source directory ID.                                }
  1229. {    srcName        input:    The source object name.                                }
  1230. {    dstDirID    input:    Destination directory ID.                            }
  1231. {    dstName        input:    Pointer to destination directory name, or            }
  1232. {                        nil when dstDirID specifies a directory.            }
  1233. {    copyName    input:    Points to the new name if the object is to be        }
  1234. {                        renamed or nil if the object isn't to be renamed.    }
  1235.  
  1236.  
  1237.  
  1238. {***************************************************************************}
  1239.  
  1240.  
  1241.     FUNCTION FSpMoveRenameCompat ({CONST}VAR srcSpec: FSSpec;
  1242.                                     {CONST}VAR dstSpec: FSSpec;
  1243.                                     copyName: StringPtr): OSErr;
  1244. {    Use FSpMoveRenameCompat to move a file or directory and optionally to    }
  1245. {    rename it. The source and destination locations must be on the same        }
  1246. {    volume. This routine works even if the volume doesn't support            }
  1247. {    MoveRename.                                                                }
  1248. {                                                                            }
  1249. {    srcSpec        input:    An FSSpec record specifying the source object.        }
  1250. {    dstSpec        input:    An FSSpec record specifying the destination            }
  1251. {                        directory.                                            }
  1252. {    copyName    input:    Points to the new name if the object is to be        }
  1253. {                        renamed or nil if the object isn't to be renamed.    }
  1254.  
  1255.  
  1256. {***************************************************************************}
  1257.  
  1258.  
  1259.     FUNCTION BuildAFPVolMountInfo (theFlags: Integer;
  1260.                                     theNBPInterval: SignedByte;
  1261.                                     theNBPCount: SignedByte;
  1262.                                     theUAMType: Integer;
  1263.                                     theZoneName: Str31;
  1264.                                     theServerName: Str31;
  1265.                                     theVolName: Str27;
  1266.                                     theUserName: Str31;
  1267.                                     theUserPassWord: Str8;
  1268.                                     theVolPassWord: Str8;
  1269.                                     theAFPInfo: MyAFPVolMountInfoPtr): OSErr;
  1270. {    Use BuildAFPVolMountInfo to initialize the fields of an AFPVolMountInfo    }
  1271. {    record before using that record to call the VolumeMount function.        }
  1272. {                                                                            }
  1273. {    theFlags        input:    The AFP mounting flags. 0 = normal mount;        }
  1274. {                            set bit 0 to inhibit greeting messages.            }
  1275. {    theNBPInterval    input:    The interval used for VolumeMount's                }
  1276. {                            NBP Lookup call. 7 is a good choice.            }
  1277. {    theNBPCount        input:    The retry count used for VolumeMount's            }
  1278. {                            NBP Lookup call. 5 is a good choice.            }
  1279. {    theUAMType        input:    The user authentication method to use.            }
  1280. {    theZoneName        input:    The AppleTalk zone name of the server.            }
  1281. {    theServerName    input:    The AFP server name.                            }
  1282. {    theVolName        input:    The AFP volume name.                            }
  1283. {    theUserName        input:    The user name (zero length Pascal string for    }
  1284. {                            guest).                                            }
  1285. {    theUserPassWord    input:    The user password (zero length Pascal string    }
  1286. {                            if no user password)                            }
  1287. {    theVolPassWord    input:    The volume password (zero length Pascal string    }
  1288. {                            if no volume password)                            }
  1289. {    theAFPInfo        input:    Pointer to AFPVolMountInfo record to            }
  1290. {                            initialize.                                        }
  1291.  
  1292.  
  1293. {***************************************************************************}
  1294.  
  1295.  
  1296.     FUNCTION RetrieveAFPVolMountInfo (theAFPInfo: AFPVolMountInfoPtr;
  1297.                                     VAR theFlags: Integer;
  1298.                                     VAR theUAMType: Integer;
  1299.                                     theZoneName: StringPtr;
  1300.                                     theServerName: StringPtr;
  1301.                                     theVolName: StringPtr;
  1302.                                     theUserName: StringPtr): OSErr;
  1303. {    Use RetrieveAFPVolMountInfo to retrieve the AFP mounting information    }
  1304. {    returned in an AFPVolMountInfo by the GetVolMountInfo function.            }
  1305. {                                                                            }
  1306. {    theAFPInfo        input:    Pointer to AFPVolMountInfo record that contains    }
  1307. {                            the AFP mounting information.                    }
  1308. {    theFlags        output:    The AFP mounting flags. 0 = normal mount;        }
  1309. {                            if bit 0 is set, greeting meesages were            }
  1310. {                            inhibited.                                        }
  1311. {    theUAMType        output:    The user authentication method used.            }
  1312. {    theZoneName        output:    The AppleTalk zone name of the server.            }
  1313. {    theServerName    output:    The AFP server name.                            }
  1314. {    theVolName        output:    The AFP volume name.                            }
  1315. {    theUserName        output:    The user name (zero length Pascal string for    }
  1316. {                            guest).                                            }
  1317.  
  1318.  
  1319. {***************************************************************************}
  1320.  
  1321.  
  1322.     FUNCTION GetUGEntries (objType: Integer;
  1323.                                     entries: UGEntryPtr;
  1324.                                     reqEntryCount: LongInt;
  1325.                                     VAR actEntryCount: LongInt;
  1326.                                     VAR objID: LongInt): OSErr;
  1327. {    Use GetUGEntries to build a list of user or group entries from the        }
  1328. {    local file server.                                                        }
  1329. {                                                                            }
  1330. {    objType            input:    The object type: -1 = group; 0 = user            }
  1331. {    UGEntries        input:    Pointer to array of UGEntry records where the    }
  1332. {                            list is returned.                                }
  1333. {    reqEntryCount    input:    The number of elements in the UGEntries array.    }
  1334. {    actEntryCount    output:    The number of entries returned.                    }
  1335. {    objID            input:    The current index position. Set to 0 to start    }
  1336. {                            with the first entry.                            }
  1337. {                    output:    The index position to get the next entry. Pass    }
  1338. {                            this value the next time you call GetUGEntries    }
  1339. {                            to start where you left off.                    }
  1340.  
  1341.  
  1342. {***************************************************************************}
  1343.  
  1344.  
  1345. IMPLEMENTATION
  1346.  
  1347. {    Functions to get information out of GetVolParmsInfoBuffer.                }
  1348.  
  1349.  
  1350.     FUNCTION isNetworkVolume (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1351.     BEGIN
  1352.         isNetworkVolume := (volParms.vMServerAdr <> 0);
  1353.     END;
  1354.  
  1355.     FUNCTION hasLimitFCBs (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1356.     BEGIN
  1357.         hasLimitFCBs := BTST(volParms.vMAttrib, bLimitFCBs);
  1358.     END;
  1359.  
  1360.     FUNCTION hasLocalWList (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1361.     BEGIN
  1362.         hasLocalWList := BTST(volParms.vMAttrib, bLocalWList);
  1363.     END;
  1364.  
  1365.     FUNCTION hasNoMiniFndr (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1366.     BEGIN
  1367.         hasNoMiniFndr := BTST(volParms.vMAttrib, bNoMiniFndr);
  1368.     END;
  1369.  
  1370.     FUNCTION hasNoVNEdit (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1371.     BEGIN
  1372.         hasNoVNEdit := BTST(volParms.vMAttrib, bNoVNEdit);
  1373.     END;
  1374.  
  1375.     FUNCTION hasNoLclSync (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1376.     BEGIN
  1377.         hasNoLclSync := BTST(volParms.vMAttrib, bNoLclSync);
  1378.     END;
  1379.  
  1380.     FUNCTION hasTrshOffLine (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1381.     BEGIN
  1382.         hasTrshOffLine := BTST(volParms.vMAttrib, bTrshOffLine);
  1383.     END;
  1384.  
  1385.     FUNCTION hasNoSwitchTo (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1386.     BEGIN
  1387.         hasNoSwitchTo := BTST(volParms.vMAttrib, bNoSwitchTo);
  1388.     END;
  1389.  
  1390.     FUNCTION hasNoDeskItems (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1391.     BEGIN
  1392.         hasNoDeskItems := BTST(volParms.vMAttrib, bNoDeskItems);
  1393.     END;
  1394.  
  1395.     FUNCTION hasNoBootBlks (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1396.     BEGIN
  1397.         hasNoBootBlks := BTST(volParms.vMAttrib, bNoBootBlks);
  1398.     END;
  1399.  
  1400.     FUNCTION hasAccessCntl (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1401.     BEGIN
  1402.         hasAccessCntl := BTST(volParms.vMAttrib, bAccessCntl);
  1403.     END;
  1404.  
  1405.     FUNCTION hasNoSysDir (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1406.     BEGIN
  1407.         hasNoSysDir := BTST(volParms.vMAttrib, bNoSysDir);
  1408.     END;
  1409.  
  1410.     FUNCTION hasExtFSVol (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1411.     BEGIN
  1412.         hasExtFSVol := BTST(volParms.vMAttrib, bHasExtFSVol);
  1413.     END;
  1414.  
  1415.     FUNCTION hasOpenDeny (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1416.     BEGIN
  1417.         hasOpenDeny := BTST(volParms.vMAttrib, bHasOpenDeny);
  1418.     END;
  1419.  
  1420.     FUNCTION hasCopyFile (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1421.     BEGIN
  1422.         hasCopyFile := BTST(volParms.vMAttrib, bHasCopyFile);
  1423.     END;
  1424.  
  1425.     FUNCTION hasMoveRename (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1426.     BEGIN
  1427.         hasMoveRename := BTST(volParms.vMAttrib, bHasMoveRename);
  1428.     END;
  1429.  
  1430.     FUNCTION hasDesktopMgr (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1431.     BEGIN
  1432.         hasDesktopMgr := BTST(volParms.vMAttrib, bHasDesktopMgr);
  1433.     END;
  1434.  
  1435.     FUNCTION hasShortName (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1436.     BEGIN
  1437.         hasShortName := BTST(volParms.vMAttrib, bHasShortName);
  1438.     END;
  1439.  
  1440.     FUNCTION hasFolderLock (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1441.     BEGIN
  1442.         hasFolderLock := BTST(volParms.vMAttrib, bHasFolderLock);
  1443.     END;
  1444.  
  1445.     FUNCTION hasPersonalAccessPrivileges (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1446.     BEGIN
  1447.         hasPersonalAccessPrivileges := BTST(volParms.vMAttrib, bHasPersonalAccessPrivileges);
  1448.     END;
  1449.  
  1450.     FUNCTION hasUserGroupList (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1451.     BEGIN
  1452.         hasUserGroupList := BTST(volParms.vMAttrib, bHasUserGroupList);
  1453.     END;
  1454.  
  1455.     FUNCTION hasCatSearch (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1456.     BEGIN
  1457.         hasCatSearch := BTST(volParms.vMAttrib, bHasCatSearch);
  1458.     END;
  1459.  
  1460.     FUNCTION hasFileIDs (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1461.     BEGIN
  1462.         hasFileIDs := BTST(volParms.vMAttrib, bHasFileIDs);
  1463.     END;
  1464.  
  1465.     FUNCTION hasBTreeMgr (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1466.     BEGIN
  1467.         hasBTreeMgr := BTST(volParms.vMAttrib, bHasBTreeMgr);
  1468.     END;
  1469.  
  1470.     FUNCTION hasBlankAccessPrivileges (VAR volParms: GetVolParmsInfoBuffer): Boolean;
  1471.     BEGIN
  1472.         hasBlankAccessPrivileges := BTST(volParms.vMAttrib, bHasBlankAccessPrivileges);
  1473.     END;
  1474.  
  1475. END.